<!DOCTYPE html>
<html>
    <head>
        <title></title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <script src="/js/jquery-1.9.1.min.js"></script>
        <script src="/js/prettify.js"></script>
        <style>
            @import "http://fonts.googleapis.com/css?family=Lato:300,400,700";
            body{
                font-family:"Lato",Arial;
        }
        </style>
    </head>
    <body>
        <a href="/">Home</a>
        <h2>AppGroup Test</h2>
        <p>This is test page for distributed cache between cluster nodes.</p>
        <p>To test the application you must run two nodes of the sample application using the following command.</p>
        <p>pluto -root "../sample/" -log "/node1_log/" -port 8001 -appgroup "samplecluster"</p>
        <p>pluto -root "../sample/" -log "/node2_log/" -port 8002 -appgroup "samplecluster"</p>
        <p>Navigate to the same page in both the nodes</p>
        <a href="http://localhost:8001/cluster.html">Node 1</a>
        <a href="http://localhost:8002/cluster.html">Node 2</a>
        <p>Use get the GET &amp; SET button.Pass the value between nodes.</p>
        <h3>Server code</h3>
        <pre class="prettyprint lang-js">
          app.map("/set",function(req,res){
                app.put(req.param("name"),req.param("value"));
                res.send("ok") ;
            });
            
          app.map("/get",function(req,res){
                res.send(app.get(req.param("name"))) ;
            });
        </pre>
        <h3>Sample HTML FORM</h3>
        Name : <input type="text" id="name"><br>
        Value : <input type="text" id="value"><br>
        Result :<span id="result"></span><br>
        <input type="button" name="GET" value="GET" id="GET">
        <input type="button" name="SET" value="SET" id="SET">
        
        <script>
            
            $(document).ready(function(){
                
                $('#GET').click(function(){
                    var dataString = 'name='+ $('#name').val();
                    $.ajax({  
                        type: "POST",  
                        url: "/get",  
                        data: dataString,  
                        success: function(data) {  
                            $('#result').html(data);    
                        }  
                    });  
                });
                 
                 $('#SET').click(function(){
                    var dataString = 'name='+ $('#name').val()+"&value="+$('#value').val();
                    $.ajax({  
                        type: "POST",  
                        url: "/set",  
                        data: dataString,  
                        success: function(data) {  
                            $('#result').html(data);    
                        }  
                    });  
                });
                
            });
        </script>
    </body>
</html>
